<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3_数据类型</title>
</head>
<body>
<script>
    // JS数据类型 = 原始类型 + 引用类型
    // 原始类型：number string boolean null undefined未定义型
    var a = 1;
    var b = 3.14;
    // typeof 变量名：此运算符可以推断变量的数据类型
    console.log(a,typeof a,b,typeof b); //整数小数都是数值类型number
    var c = '你好';
    var d = "你们好！";
    console.log(c,typeof c,d,typeof d); //单引号双引号都是字符串类型string
    var e = true;
    var f = false;
    console.log(e,typeof e,f,typeof f) //true与false是布尔类型boolean
    //声明了变量但未赋值，就会得到undefined未定义型
    var g;
    console.log(g,typeof g);

    //引用类型 Object Number String Boolean Array...
    //1)自定义对象 Cat c = new Cat()
    let obj = {
        name:'张三',
        age:18
    }
    console.log(obj,typeof obj); //{name:'张三',age:18} 'object'
    console.log(obj.name); //张三
    console.log(obj.age); //18

    obj.age = 19;
    console.log(obj.age);
    obj.like = '给祖国母亲庆生'
    console.log(obj); //{"name":"张三","age":19,"like":“给祖国母亲庆生!”}
    console.log(obj.like); //给祖国母亲庆生!
    console.log(obj.play); //undefined 访问对象不存在的属性会得到undefiend!

    //JS数组
    let arr = ['李逵',1,6.6,false];
    console.log(arr,typeof arr);
    console.log(arr[0]);
    console.log(arr[3]);
    console.log(arr[99]); //访问数组不存在的下表，会得到undefiend
</script>
</body>
</html>